// --------------------------------------------------------------------------------------------------------------------
// <copyright file="LocalizationRequiredAttribute.cs" company="CSLib.Net Team">
//   Copyright (c) Roman "4ux-nbIx" Novitsky 2010
// </copyright>
// <summary>
//   Indicates that marked element should be localized or not.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace CSLib.Net.Annotations
{
  #region Namespace Imports

  using System;
  using System.Diagnostics.CodeAnalysis;

  #endregion


  /// <summary>
  /// Indicates that marked element should be localized or not.
  /// </summary>
  [SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments", 
    Justification = "Not sure whether it is possible.")]
  [AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
  public sealed class LocalizationRequiredAttribute : Attribute
  {
    #region Constructors and Destructors

    /// <summary>
    /// Initializes a new instance of the <see cref="LocalizationRequiredAttribute"/> class.
    /// </summary>
    /// <param name="required">
    /// <c>True</c> if a element should be localized; otherwise, <c>false</c>.
    /// </param>
    public LocalizationRequiredAttribute(bool required)
    {
      Required = required;
    }

    #endregion


    #region Properties

    /// <summary>
    /// Gets or sets a value indicating whether a element should be localized.
    /// </summary>
    /// <value>
    /// <c>True</c> if a element should be localized; otherwise, <c>false</c>.
    /// </value>
    public bool Required
    {
      get;
      set;
    }

    #endregion


    #region Public Methods

    /// <summary>
    /// Returns whether the value of the given object is equal to the current <see cref="LocalizationRequiredAttribute"/>.
    /// </summary>
    /// <param name="obj">
    /// The object to test the value equality of. 
    /// </param>
    /// <returns>
    /// <c>true</c> if the value of the given object is equal to that of the current; otherwise, <c>false</c>.
    /// </returns>
    public override bool Equals(object obj)
    {
      var attribute = obj as LocalizationRequiredAttribute;
      return attribute != null && attribute.Required == Required;
    }


    /// <summary>
    /// Returns the hash code for this instance.
    /// </summary>
    /// <returns>
    /// A hash code for the current <see cref="LocalizationRequiredAttribute"/>.
    /// </returns>
    public override int GetHashCode()
    {
      return base.GetHashCode();
    }

    #endregion
  }
}